load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "statistics",
    srcs = [
        "analyze.go",
        "analyze_jobs.go",
        "builder.go",
        "builder_ext_stats.go",
        "cmsketch.go",
        "cmsketch_util.go",
        "column.go",
        "debugtrace.go",
        "estimate.go",
        "fmsketch.go",
        "histogram.go",
        "index.go",
        "row_sampler.go",
        "sample.go",
        "scalar.go",
        "table.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/statistics",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/expression",
        "//pkg/kv",
        "//pkg/parser/ast",
        "//pkg/parser/charset",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/terror",
        "//pkg/planner/util/debugtrace",
        "//pkg/sessionctx",
        "//pkg/sessionctx/stmtctx",
        "//pkg/sessionctx/variable",
        "//pkg/statistics/handle/logutil",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util/chunk",
        "//pkg/util/codec",
        "//pkg/util/collate",
        "//pkg/util/dbterror",
        "//pkg/util/fastrand",
        "//pkg/util/hack",
        "//pkg/util/intest",
        "//pkg/util/logutil",
        "//pkg/util/memory",
        "//pkg/util/ranger",
        "//pkg/util/sqlexec",
        "@com_github_dolthub_swiss//:swiss",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_twmb_murmur3//:murmur3",
        "@org_golang_x_exp//maps",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "statistics_test",
    timeout = "short",
    srcs = [
        "bench_daily_test.go",
        "builder_test.go",
        "cmsketch_test.go",
        "fmsketch_test.go",
        "histogram_bench_test.go",
        "histogram_test.go",
        "integration_test.go",
        "main_test.go",
        "sample_test.go",
        "scalar_test.go",
        "statistics_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":statistics"],
    flaky = True,
    shard_count = 35,
    deps = [
        "//pkg/config",
        "//pkg/parser/ast",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/sessionctx",
        "//pkg/sessionctx/stmtctx",
        "//pkg/statistics/handle/autoanalyze",
        "//pkg/testkit",
        "//pkg/testkit/testdata",
        "//pkg/testkit/testmain",
        "//pkg/testkit/testsetup",
        "//pkg/types",
        "//pkg/util/benchdaily",
        "//pkg/util/chunk",
        "//pkg/util/codec",
        "//pkg/util/collate",
        "//pkg/util/memory",
        "//pkg/util/mock",
        "//pkg/util/ranger",
        "//pkg/util/sqlexec",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
